package locations.actions;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import locations.dao.implement.EspecialidadDAOHibernateJPA;
import locations.model.Especialidad;

public class EditSpecialityAction extends ActionSupport implements ModelDriven<Especialidad>, ServletRequestAware  {
	
    private static final long serialVersionUID = -8124967730231198191L;

    private HttpServletRequest request; 
    private Especialidad speciality = new Especialidad();

    public String execute(){
            Long id = Long.parseLong(this.getRequest().getParameter("id"));
            EspecialidadDAOHibernateJPA dao = new EspecialidadDAOHibernateJPA();
            this.speciality = dao.retrieveById(id);
            return SUCCESS;
    }

    public Especialidad getSpeciality() {
            return speciality;
    }

    public void setSpeciality(Especialidad speciality) {
            this.speciality = speciality;
    }

    @Override
    public Especialidad getModel() {
            return this.speciality;
    }

    public HttpServletRequest getRequest() {
            return request;
    }

    @Override
    public void setServletRequest(HttpServletRequest request) {
            this.request = request;

    }
}